﻿@model Matrix.MaKaYunShang.Model.CommodityBrand

@{
    ViewBag.Title = "添加品牌";
    ViewBag.PathToBtn = "/CommodityBrand/List";
    ViewBag.TextBtn = "返回至列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- /.row -->
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                品牌信息
            </div>
            <div class="panel-body">
                <div class="row">
                    @using (Html.BeginForm("Create", "CommodityBrand", FormMethod.Post, new {id = "frmCreate", enctype = "multipart/form-data"}))
                    {
                        @Html.AntiForgeryToken()
                        @Html.ValidationSummary(true)

                        <div class="col-lg-12">
                            <fieldset>
                                <div class="form-group col-md-6">
                                    <label>品牌名称</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BrandName, new {@class = "form-control", placeholder = "名称"})
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <label>品牌英文/拼音名称</label>
                                    <div class="input-group">
                                        @Html.TextBoxFor(model => model.BrandLetterName, new {@class = "form-control", placeholder = "英文/拼音名称"})
                                        <span class="input-group-addon red">必填</span>
                                    </div>
                                </div>
                                <div class="form-group col-md-6">
                                    <input id="fileImage" class="form-control" type="file" name="fileImage" style="display: none;" />
                                    <input id="btnSelect" type=button class="btn btn-info" value="上传Logo" onclick="fileImage.click()"/>
                                    <img id="imgThumb" alt="缩略图" style="max-height: 80px" src="/Content/admin/image/uploadimg.png" imgpath="/Content/admin/image/uploadimg.png" />
                                    <span>（建议尺寸：宽50*高50，200KB以内）</span>
                                </div>

                                <div class="col-md-12">
                                    <button id="btnSave" type="submit" class="btn btn-primary">确定并保存</button>
                                    <button id="btnReset" type="reset" class="btn btn-outline btn-primary">清空设置</button>
                                </div>
                            </fieldset>
                        </div>
                    }
                </div>
                <!-- /.row (nested) -->
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /.panel -->
    </div>
    <!-- /.col-lg-12 -->
</div>
<!-- /.row -->

@section javascript{
    <script src="/Content/admin/dist/js/imageUploader.js"> </script>
    <script type="text/javascript">
        // Image Upload
        imageUploader.uploadSingle(fileImage, btnSelect, imgThumb, '');

        $(function() {
            $("#frmCreate").validate({
                rules: {
                    BrandName: { required: true },
                    BrandLetterName: { required: true }
                },
                messages: {
                    BrandName: { required: "请填写品牌名称" },
                    BrandLetterName: { required: "请填写品牌英文/拼音名称" }
                },
                submitHandler: function(form) {
                    form.submit();
                }
            });
        });

    </script>
}